<script>
    function Add_gallery_type() {
	window.location.href = "?modul=gallery&action=add_gallery_slide_home";
    }
</script>

<?php

function V_Gallery_Slide_Home($arrayData, $mode, $id) {
    $ulr = "?" . MODUL . "=gallery&" . ACTION . "=";
    if ($mode == "gallery_slide_home") {
	$strLabel = "Danh sách ảnh slide banner";
    } else if ($mode == "gallery_home") {
	$strLabel = "Danh sách ảnh đẹp trang chủ";
    }
    ?>
    <h3><?= $strLabel ?></h3>
    <form name="frm" action="<?= $ulr . $mode ?>"  method="post" enctype="multipart/form-data">
    <!--<p style="float: right"><input type="button" value="Thêm mới" onclick="Add_gallery_type();" /></p><br/>-->
        <table width="100%" cellpadding="5" border="1">
    	 <tr style="background-color: #99CCFF">
    	    <th width="15px">STT</th>
    	    <th width="500px">Ảnh</th>
    	    <th width="30px">Sửa</th>
    	    <th width="30px">Xóa</th>
    	</tr>
	    <?
	    if (!empty($arrayData)) {
		$a = 0;
		foreach ($arrayData as $value) {
		    $a++;
		    ?>
	    	<tr>
	    	    <td><?= $a ?></td>		
	    	    <td width="500px">
	    		<img width="500px" src="<?= DIR_SLIDER . $value['url_pic'] ?>" />
	    	    </td>
	    	    <td>
			    <? if ($id == $value['id']) { ?>
				<input type="file" name="url_pic" id="url_pic"/>
				<br/>
				<br/>
				<input type="submit" name="Submit" value="Lưu"/>
				<input type="hidden" name="id" id="id" value="<?= $id ?>"/>
			    <? } else { ?>
				<a href="<?= $ulr . $mode . "&id=" . $value['id'] ?>">Sửa</a>
			    <? } ?>
	    	    </td>
	    	    <td><a onclick="return confirm('Bạn có chắc chắn muốn xóa không?');" href="<?= $ulr . "Del_pic&id=" . $value['id'] ."&flag=gallery_slide_home"?>">Xóa</a></td>
	    	</tr>
		    <?
		}
	    } else {
		echo "<tr><td colspan='4'>Khong co anh</td></tr>";
	    }
	    ?>
		<tr>
		    <th colspan="4">Thêm mới ảnh Slide Banner</th>
		</tr>
		<tr>
		    <th colspan="4">
			<input type="file" multiple="multiple" name="url_pic_up[]" id="url_pic_up"/><br/>
			<input type="submit" name="upload_slide" id="upload_slide" value="Upload"/><br/>
		    </th>
		</tr>
        </table>
    </form>
    <?
}
?>
